package com.example.charlotte.snakegame;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Charlotte on 2018/12/12.
 */

public class DBHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME="mydata";
    private static final String TABLE_NAME="users";
    private static final int DATABASE_VERSION=1;
    public DBHelper(Context context) {
        super(context, DATABASE_NAME,null,DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table "+TABLE_NAME+"(_id integer primary key autoincrement,username text,password text,score int,title text)";
        db.execSQL(sql);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists "+TABLE_NAME);
        onCreate(db);
    }
}
